﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HRM.Data.Database;

namespace HRM.Data.Repository
{
    public class RoleRepository: BaseRepository<Role>
    {
        public override IEnumerable<Role> GetList()
        {
            return _database.Roles.ToList();
        }

        public override Role GetById(long id)
        {
            return _database.Roles.Find(id);
        }

        public override void Create(Role entity)
        {
            _database.Roles.Add(entity);
            SaveChanges();
        }

        public override void Update(Role entity)
        {
            var tempEntity = _database.Roles.Find(entity);
            _database.Entry(tempEntity).CurrentValues.SetValues(entity);
            SaveChanges();
        }

        public override void Delete(Role entity)
        {
            _database.Roles.Remove(entity);
        }
    }
}
